﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using myBoard.App.Components.MagnetsStore.ViewsModels;

namespace myBoard.App
{
	/// <summary>
	/// Interaction logic for MagnetDetails.xaml
	/// </summary>
	public partial class MagnetDetails : UserControl
	{
		public MagnetDetails()
		{
			this.InitializeComponent();
            _openMagnetDllBt.Click += new RoutedEventHandler(_openMagnetDllBt_Click);
            _openThumbnailBt.Click += new RoutedEventHandler(_openThumbnailBt_Click);
            _addScreenshotBt.Click += new RoutedEventHandler(_addScreenshotBt_Click);            
		}

        void _openMagnetDllBt_Click(object sender, RoutedEventArgs e)
        {
            MagnetViewModel mvm = this.DataContext as MagnetViewModel;
            if (mvm == null)
                return;
            
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Title = "Select your magnet";
            ofd.Filter = "Magnet files (*.mgt)|*.mgt";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                mvm.MagnetPath = ofd.FileName;
            }
        }

        void _addScreenshotBt_Click(object sender, RoutedEventArgs e)
        {
            MagnetViewModel mvm = this.DataContext as MagnetViewModel;
            if (mvm == null)
                return;
            
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Title = "Select a screenshot";
            ofd.Filter = "PNG files (*.png)|*.png";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                mvm.ScreenshotsPath.Add(ofd.FileName);
            }
        }

        void _openThumbnailBt_Click(object sender, RoutedEventArgs e)
        {
            MagnetViewModel mvm = this.DataContext as MagnetViewModel;
            if (mvm == null)
                return;

            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Title = "Select your magnet";
            ofd.Filter = "PNG files (*.png)|*.png";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                mvm.ThumbnailPath = ofd.FileName;
                
            }

        }
	}
}